/*
 *  WaveFunctionSinPowerOfX.cpp
 *  SoundController0002
 *
 *  Created by jiro on 10/11/20.
 *  Copyright 2010 jiro music. All rights reserved.
 *
 */

#include "WaveFunctionSinPowerOfX.h"

namespace sc { 

	double WaveFunctionSinPowerOfX::operator() ( double x ) const
	{
		return std::sin( 2 * Pi * cycle * std::pow( slopeOfX * x + interceptOfX, powerOfX ) );
	}

	bool WaveFunctionSinPowerOfX::operator == ( const WaveFunction& rhs ) const
	{
		if ( ! this->WaveFunction::operator == ( rhs ) ) {
			return false;
		}
		const WaveFunctionSinPowerOfX& ref = dynamic_cast<const WaveFunctionSinPowerOfX& >( rhs );
		if ( powerOfX == ref.powerOfX ) {
			return true;
		}
		return false;
	}

	bool WaveFunctionSinPowerOfX::operator != ( const WaveFunction& rhs ) const
	{
		return not ( * this == rhs );
	}

	bool WaveFunctionSinPowerOfX::operator < ( const WaveFunction& rhs ) const
	{
		if ( type != rhs.GetType() ) {
			return type < rhs.GetType();
		}
		if ( this->WaveFunction::operator < ( rhs ) ) {
			return true;
		}
		const WaveFunctionSinPowerOfX& ref = dynamic_cast<const WaveFunctionSinPowerOfX& >( rhs );
		return powerOfX < ref.powerOfX;
	}

	WaveFunctionSinPowerOfX::WaveFunctionSinPowerOfX( double powerOfX, double cycle )
		: WaveFunction( Type_SinPowerOfX, cycle, 1.0, 1.0, 0.0 ),
		  powerOfX( powerOfX )
	{}

}
